package com.higgins.lawapp.client.settings.components;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;

public class DataSourceFieldFields extends DataSourceComponent	{
	private final Label label = new Label();
    private final TextBox start = new TextBox();
    private final TextBox end = new TextBox();
    private final TextBox fieldName = new TextBox();
    private final CheckBox url = new CheckBox();
    private final CheckBox concat = new CheckBox();

    public DataSourceFieldFields(String fieldNameText, String startText, String endText, Boolean urlValue, Boolean concatValue)	{
    	instantiate();
    	fieldName.setText(fieldNameText);
    	start.setText(startText);
    	end.setText(endText);
    	url.setValue(urlValue);
    	concat.setValue(concatValue);
    }
    public DataSourceFieldFields()	{
    	instantiate();
    }
    public void instantiate()	{
    	this.setComponentType("Field");
	    label.setText("Field");
	    fieldName.setTitle("Field Name");
	    start.setTitle("Field Start");
	    end.setTitle("Field End");
	    url.setValue(false);
	    url.setTitle("URL");
	    url.setText("URL");
	    fieldName.setText("");
	    start.setText("");
	    end.setText("");
	    concat.setText("concat");
	    add(label);
	    add(fieldName);
	    add(start);
	    add(end);
	    add(url);
	    add(concat);
	    setWidgetLeftWidth(label, 0, Unit.PCT, 33, Unit.PCT);
	    setWidgetLeftWidth(fieldName, 33, Unit.PCT, 18, Unit.PCT);
	    setWidgetLeftWidth(start, 51, Unit.PCT, 18, Unit.PCT);
	    setWidgetLeftWidth(end, 69, Unit.PCT, 16, Unit.PCT);
	    setWidgetLeftWidth(url, 85, Unit.PCT, 7, Unit.PCT);
	    setWidgetRightWidth(concat, 0, Unit.PCT, 7, Unit.PCT);
	   }
    public String getFieldName()	{
    	return fieldName.getText();
    }
    public String getStart()	{
    	return start.getText();
    }
    public String getEnd()	{
    	return end.getText();
    }
    public boolean isURL()	{
    	boolean checkedOrNot = url.getValue();
    	return url.getValue();
    }
    public boolean isConcat()	{
    	return concat.getValue();
    }
}
